const express = require('express')
const app = express()

app.use(express.json())
app.use(express.urlencoded({extended:false}))


/* app.use((req,res,next)=>{
    res.setHeader('Access-Control-Allow-Origin','*')
    next()
}) */

/* app.use((req,res,next)=>{
    res.setHeader('Access-Control-Allow-Origin','*')
    next()
}) */
app.use((req,res,next)=>{
    res.setHeader('Access-Control-Allow-Origin','*')
    next()
})

app.get('/home',(req,res)=>{
    res.send({
        status:200,
        name:'home',
        msg:'express 接口编写',
        data:[req.query]
    })
})

app.post('/add',(req,res)=>{
    res.send({
        status:200,
        name:'home',
        msg:'express 接口编写',
        data:[req.body]
    })
})

app.listen(8080, () => {
    console.log("8080 running");
  });